﻿using Dal.Iterfease;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace xiaomiApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SiteController : ControllerBase
    {
        private readonly IsiteDal _userDal;

        public SiteController(IsiteDal userDal)
        {
            _userDal = userDal;
        }

        /// <summary>
        /// 三级联动
        /// </summary>
        /// <param name="Ssid"></param>
        /// <returns></returns>
        [HttpGet, Route("getSsx")]
        public IActionResult getSsx(int Ssid)
        {
            return Ok(_userDal.getSsx(Ssid));
        }

        /// <summary>
        /// 地址详情显示
        /// </summary>
        /// <param name="Suid"></param>
        /// <returns></returns>
        [HttpGet, Route("getSite")]
        public IActionResult getSite(int Suid)
        {
            return Ok(_userDal.getSite(Suid));
        }

        /// <summary>
        /// 添加地址
        /// </summary>
        /// <param name="sit"></param>
        /// <param name="Suid"></param>
        /// <returns></returns>
        [HttpPost, Route("AddSite")]
        public IActionResult AddSite( siteInfo sit)
        {
            return Ok(_userDal.AddSite(sit));
        }


        /// <summary>
        /// 删除地址
        /// </summary>
        /// <param name="Sid"></param>
        /// <returns></returns>
        [HttpGet, Route("DelSite")]
        public IActionResult DelSite(int Sid)
        {
            return Ok(_userDal.DelSite(Sid));
        }

        /// <summary>
        /// 修改地址
        /// </summary>
        /// <param name="sit"></param>
        /// <returns></returns>
        [HttpPost,Route("UpStie")]
        public IActionResult UpStie(siteInfo sit)
        {
            return Ok(_userDal.UpStie(sit));
        }
    }
}
